const path = require('path')
const resolve = dir => {
  return path.join(__dirname, dir)
}
const root = path.dirname(path.dirname(__dirname))
module.exports = {
  css: {
    loaderOptions: {
      stylus: {
        'resolve url': true,
        'import': [
          './src/theme'
        ]
      }
    }
  },
  pluginOptions: {
    'cube-ui': {
      postCompile: true,
      theme: true
    }
  },
  chainWebpack: config => {
    config.resolve.alias
        .set('@', resolve('src'))
        .set('@c', resolve('src/components'))
        .set('@v', resolve('src/views'))
        .set('@a', resolve('src/assets')),
    config.plugin('html')
        .tap(args => {
          args[0].load = process.env.NODE_ENV === "production" ?
              '{!! $script !!}' :
              '<script src=\'https://webapi.amap.com/maps?v=1.4.15&key=8cf05187899e24feccadddef60b77351&plugin=AMap.Geolocation,AMap.Geocoder\'></script><script>window.cool = {app_name: \'有趣红1包\'}</script>'
          return args
        })
  },
  publicPath: process.env.NODE_ENV === 'production'
      ? '/dist/app/'
      : '/',
  outputDir: root + '/public/dist/app',
  assetsDir: '.',
  indexPath: root + '/resources/views/app.blade.php'
}
